<#include "header.htm"/>

<#import "../macros/pagination.ftl" as pagination>
<#import "../macros/presentation.ftl" as presentation/>

<script type="text/javascript" src="${contextPath}/templates/${templateName}/js/pagination.js?${startupTime}"></script>

<table cellspacing="0" cellpadding="1" width="100%" align="center" border="0">
	<tr>
		<td class="bodyline" valign="top">
			<table cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
				<tr>
					<td valign="bottom" align="left" colspan="2">
						<span class="maintitle">${I18n.getMessage("Search.searchResults")}:
							${totalRecords} <#if (totalRecords == 1)>${I18n.getMessage("Search.recordFound")}<#else>${I18n.getMessage("Search.recordsFound")}</#if>
						</span>
						<br />
					</td>
				</tr>
				<tr>
					<td align="left" valign="middle">		  
						<a class="nav" href="${contextPath}/forums/list${extension}">${I18n.getMessage("ForumListing.forumIndex")}</a>
					</td>

					<td valign="bottom" nowrap="nowrap" align="right">
						<#assign paginationLinks>
							<@pagination.doPagination action/>
						</#assign>

						${paginationLinks}
					</td>
				</tr>
			</table>

			<table class="forumline" cellspacing="1" cellpadding="1" width="100%" border="0">
				<tr>
					<th class="thcornerl" nowrap="nowrap" align="center" width="26">&nbsp;${I18n.getMessage("ForumBase.state")}&nbsp;</th>
					<th class="thcornerl" nowrap="nowrap" align="center" width="120">&nbsp;${I18n.getMessage("Forums.Form.ForumName")}&nbsp;</th>
					<th class="thcornerl" nowrap="nowrap" align="center">&nbsp;${I18n.getMessage("ForumIndex.topics")}&nbsp;</th>
					<th class="thtop" nowrap="nowrap" align="center" width="50">&nbsp;${I18n.getMessage("ForumIndex.answers")}&nbsp;</th>
					<th class="thtop" nowrap="nowrap" align="center" width="100">&nbsp;${I18n.getMessage("ForumIndex.author")}&nbsp;</th>
					<th class="thtop" nowrap="nowrap" align="center" width="50">&nbsp;${I18n.getMessage("ForumIndex.views")}&nbsp;</th>
					<th class="thcornerr" nowrap="nowrap" align="center" width="100">&nbsp;${I18n.getMessage("ForumIndex.lastMessage")}&nbsp;</th>
				</tr>
			
				<!-- TOPICS LISTING -->
				<#list results as topic>
					<#assign forum = fr.getForum(topic.forumId)/>
					<#assign rowbg><@presentation.rowbg topic/></#assign>

					<tr>
						<td bgcolor="${rowbg}" valign="middle" align="center" width="20">
							<@presentation.folderImage topic/>
						</td>
						<td bgcolor="${rowbg}"  width="120" valign="middle" align="center">
							<a class="postdetails" href="${contextPath}/forums/show/${forum.id}${extension}" >${forum.name}</a>
						</td>
						<td bgcolor="${rowbg}" onmouseover="style.backgroundColor='#F5EFFB'" onmouseout="style.backgroundColor='${rowbg}'">
							<a href="${contextPath}/posts/list/${topic.id}${extension}" class="topictitle"><#if (topic.title?length == 0)>No Subject<#else>${topic.title?html}</#if></a>
						
						</td>
						<td bgcolor="${rowbg}" valign="middle" align="center" nowrap="nowrap">
							<span class="postdetails">${topic.totalReplies}</span>
						</td>
					    <td bgcolor="${rowbg}"  valign="middle" align="center" nowrap="nowrap">
					       <span class="name">${topic.firstPostTime} <br />
						   <a href="${JForumContext.encodeURL("/user/profile/${topic.postedBy.id}")}" target="_blank">${topic.postedBy.username}</a></span>
					    </td>
						<td bgcolor="${rowbg}" valign="middle" align="center" nowrap="nowrap">
							${topic.totalViews}
						</td>
						<td bgcolor="${rowbg}" valign="middle" nowrap="nowrap" align="center">
							<#if (topic.lastPostTime?length > 0)>
								<span class="name">${topic.lastPostTime}<br />
								<a href="${contextPath}/user/profile/${topic.lastPostBy.id}${extension}">${topic.lastPostBy.username}</a>

								<#assign startPage = ""/>
								<#if (topic.totalReplies + 1 > postsPerPage)>
									<#assign startPage = ((topic.totalReplies / postsPerPage)?int * postsPerPage) +"/"/>
								</#if>
								<a href="${contextPath}/posts/list/${startPage}${topic.id}${extension}#${topic.lastPostId}"><img src="${contextPath}/templates/${templateName}/images/icon_latest_reply.gif" border="0" alt="[Latest Reply]" /></a>
								</span>
							</#if>
						</td>
					</tr>
				</#list>		
				<!-- END OF TOPICS LISTING -->

				<tr>
					<td class="catbottom" valign="middle" align="right" colspan="7" height="28">&nbsp;</td>
				</tr>
			</table>
		
			<table cellspacing="1" cellpadding="1" width="100%" align="center" border="0">
				<tr>
					<td align="left" valign="middle">
						<a class="nav" href="${contextPath}/forums/list${extension}">${I18n.getMessage("ForumListing.forumIndex")}</a>
					</td>
					<td valign="middle" nowrap="nowrap" align="right">
						${paginationLinks}
					</td>
				</tr>
				<tr>
					<td align="left" colspan="2">&nbsp;</td>
				</tr>
			</table>
			 
			<table cellspacing="0" cellpadding="0" width="100%" border="0">
				<tr>
					<td align="right">
						<table cellspacing="0" cellpadding="0" border="0">
							<tr>			  
								<td nowrap="nowrap">
									<form action="" accept-charset="${encoding}" name="f">
										<span class="gensmall">${I18n.getMessage("ForumIndex.goTo")}:&nbsp;
										<select onchange="if(this.options[this.selectedIndex].value != -1){ document.location = '${contextPath}/forums/show/'+ this.options[this.selectedIndex].value +'${extension}'; }" name="select">
											<option value="-1" selected="selected">${I18n.getMessage("ForumIndex.goToSelectAForum")}</option>				
												<#list categories as category>
													<optgroup label="${category.name}">
														<#list category.getForums() as forum>
														<option value="${forum.id}">${forum.name}</option>
														</#list>
													</optgroup>
												</#list>
										</select>				  
										&nbsp;
										<input class="liteoption" type="button" value="${I18n.getMessage("ForumIndex.goToGo")}" onclick="if(document.f.select.options[document.f.select.selectedIndex].value != -1){ document.location = '${contextPath}/forums/show/'+ document.f.select.options[document.f.select.selectedIndex].value +'${extension}'; }" />
										</span>
									</form>
								</td>
							</tr>
						</table>
					</td>
				</tr>
			</table>
 		
		</td>
	</tr>
</table>

<#include "bottom.htm"/>
